package com.java28.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.java28.pojo.Dept;
import com.java28.service.DeptService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("dept")
//@RestController
public class DeptController {

    @Resource
    DeptService deptService;

    @RequestMapping("dept")
    public @ResponseBody Map list(@RequestParam(value = "nowPage",defaultValue = "1") Integer nowPage){
        PageHelper.startPage(nowPage,2);
        List<Dept> deptList = deptService.list();
        PageInfo<Dept> deptPageInfo = new PageInfo<Dept>(deptList);
        Map<String,Object> deptMap = new HashMap<String,Object>();
        deptMap.put("deptList",deptList);
        deptMap.put("deptPageInfo",deptPageInfo);
        deptMap.put("message","ok");
        return deptMap;
    }


}
